<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.lob.*"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%
 
	    String filename= null;
	    String fileId = request.getParameter("fileId");
		String upload = request.getParameter("upload");
	    String resourceId = request.getParameter("resourceId");

        LobDataService lobDataService = (LobDataService) ContextFactory.getBean("lobDataService");
        LobData lob = null;
		if( StringUtils.isNotEmpty(resourceId)) {
			 lob = lobDataService.getMaxLobData(resourceId);
		}  
        if(lob != null ){
			   fileId = String.valueOf(lob.getFileId());
			   filename = lob.getFilename();
		} else {
			   Calendar rightNow = Calendar.getInstance();
			   filename = (new Integer(rightNow.get(Calendar.MONTH))).toString()+ rightNow.get(Calendar.YEAR) 
					+ rightNow.get(Calendar.DAY_OF_MONTH)
					+ rightNow.get(Calendar.MINUTE) + rightNow.get(Calendar.SECOND)+".doc"; //缺省文件名
	   }
	   if(fileId == null){
		   fileId = "";
	   }
	   if(upload == null){
		   upload = "";
	   }
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=GBK">
<script language="javascript" src="ntkoocx.js"></script>
<script language="javascript" src="ntkoCustomMenu.js"></script>
<title>编辑文档</title>
<style>
button.op{
width:90px;
background-color:#9DC2DB;
border:1px #EEEEEE solid;
cursor: hand;
}
</style>
<script language="javascript">
   var  contextPath = "<%=request.getContextPath()%>";
   function showMenubar(){
	   if(TANGER_OCX_OBJ.Menubar==false){
		   TANGER_OCX_OBJ.Menubar=true;
	   } else {
		   TANGER_OCX_OBJ.Menubar=false;
	   }
   }

  function showToolbar(){
	   if(TANGER_OCX_OBJ.Toolbars==false){
		   TANGER_OCX_OBJ.Toolbars=true;
	   } else {
		   TANGER_OCX_OBJ.Toolbars=false;
	   }
   }

</script>
</head>
<body topmargin="0" leftmargin="0" onLoad='javascript:openDoc("false");'>
<center>
<form id="myForm" method="post" enctype="multipart/form-data" 
           action="uploadedit.jsp?resourceId=<%= resourceId %>&fileId=<%= fileId %>">
<input type="hidden" id="filename" name="filename"  value="<%= filename %>">
<input type="hidden" id="editFileUrl" name="editFileUrl"  
           value="readdoc.jsp?method=download&fileId=<%=fileId%>&resourceId=<%=resourceId%>">

<table width=100% height=700 border=1 cellpadding=0 cellspacing=0 style="border:0px #9dc2db solid">
<tr width=100%><td valign=top width=100% style="background-color:#9DC2DB;">
   <%if("true".equals(upload)){%>
    <button class="op" onclick="TANGER_OCX_SaveEditToServer();">保存到服务器</BUTTON>
   <%}%>
	<button class="op" onclick="showMenubar();">菜单栏</button>
	<button class="op" onclick="showToolbar();">工具栏</button>
	<button class="op" onclick="TANGER_OCX_PrintDoc()">打印</button>
</td>
</tr>
<tr>
<td width=100% valign="top" height="800">		
	<script language=javascript src="<%=request.getContextPath()%>/pages/ntko/ntkoocxreg.js"></script>
	<!-- 以下函数相应控件的两个事件:OnDocumentClosed,和OnDocumentOpened -->
	<script language="JScript" for=TANGER_OCX event="OnDocumentClosed()">
		TANGER_OCX_OnDocumentClosed();
	</script>
	<script language="JScript" for=TANGER_OCX event="OnDocumentOpened(TANGER_OCX_str,TANGER_OCX_obj)">
		TANGER_OCX_OnDocumentOpened(TANGER_OCX_str,TANGER_OCX_obj);
		TANGER_OCX_OBJ.Titlebar = false;
		TANGER_OCX_OBJ.FileClose = false;//禁用“关闭”菜单
		TANGER_OCX_OBJ.Menubar = true;
		TANGER_OCX_OBJ.Toolbars = true;
		TANGER_OCX_OBJ.ActiveDocument.ActiveWindow.View.Zoom.Percentage = 85;
		 try{
               initCustomMenu();
		   }catch(exe){
		   }
	</script>
 </td>
 </tr>
</table>	
</form>
<script language="javascript">
	  
</script>
</center>
</body>
</html>